package com.xbongbong.crm.perform.query.detail;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.crm.abstracts.AbstractCrmDetailTopInfoService;
import com.xbongbong.crm.service.permission.ContactPermissionServiceImpl;
import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.call.CallCenterService;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.domain.entity.ext.PaasFormEntityExt;
import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.enums.PlatFormEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.LinkListPojo;
import com.xbongbong.paas.help.CommonHelp;
import com.xbongbong.paas.help.FormDataFormExplainHelper;
import com.xbongbong.paas.model.PaasAppModel;
import com.xbongbong.paas.model.PaasMenuModel;
import com.xbongbong.paas.pojo.CustomerUserPojo;
import com.xbongbong.paas.pojo.DetailTabPojo;
import com.xbongbong.paas.pojo.FormTitlePoJo;
import com.xbongbong.paas.pojo.HandelDetailPojo;
import com.xbongbong.paas.pojo.SummaryDataPoJo;
import com.xbongbong.paas.pojo.vo.FormDataGetVO;
import com.xbongbong.paas.pojo.vo.ParseSingleRowDataVO;
import com.xbongbong.paas.service.DetailTabConfigService;
import com.xbongbong.paas.service.LinkListService;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.BeanUtil;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import com.xbongbong.paas.util.ExplainUtil;
import com.xbongbong.paas.util.TitleUtil;
import com.xbongbong.parent.parse.data.FormDataGetAnalysisDataHelp;
import com.xbongbong.pro.appdetail.pojo.MobileDetailDirectBlockPojo;
import com.xbongbong.pro.appdetail.pojo.MobileDetailManagerBlockPojo;
import com.xbongbong.pro.appdetail.pojo.MobileDetailMoneyItemPojo;
import com.xbongbong.pro.appdetail.pojo.MobileDetailScriptPojo;
import com.xbongbong.pro.appdetail.pojo.MobileDetailStatusPojo;
import com.xbongbong.pro.constant.I18nStringConstant;
import com.xbongbong.pro.enums.DistributorMarkEnum;
import com.xbongbong.pro.enums.permission.enums.ProPermissionAliasEnum;
import com.xbongbong.pro.enums.permission.enums.UpdateProPermissionAliasEnum;
import com.xbongbong.pro.form.pojo.TopPermissionsPoJo;
import com.xbongbong.pro.formdata.pojo.dto.FormDataDetailDTO;
import com.xbongbong.pro.formexplain.pojo.dto.HandlerExplainDTO;
import com.xbongbong.pro.formexplain.pojo.vo.HandlerExplainVO;
import com.xbongbong.paas.service.BusinessButtonService;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.domain.entity.ContactUserEntity;
import com.xbongbong.saas.enums.BusinessDetailTabEnum;
import com.xbongbong.saas.enums.MobileDetailBottomOperationEnum;
import com.xbongbong.saas.enums.WorkFlowEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.ContactEnum;
import com.xbongbong.saas.model.ContactUserModel;
import com.xbongbong.saas.service.toolbox.help.UserTeamHelp;
import com.xbongbong.saas.toolbox.help.FastJsonHelper;
import com.xbongbong.sys.domain.entity.UserEntity;
import com.xbongbong.sys.model.UserModel;
import com.xbongbong.util.NameUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author sunshaoxiang
 * @ClassName ContactDetailTopInfoServiceImpl
 * @Description 联系人表单上层信息业务层
 * @Date 2022/5/17 19:18
 * @Version 1.0
 **/
@Service("contactDetailTopInfoServiceImpl")
public class ContactDetailTopInfoServiceImpl extends AbstractCrmDetailTopInfoService {

    private static final Logger LOGGER = LoggerFactory.getLogger(ContactDetailTopInfoServiceImpl.class);

    @Resource
    private UserModel userModel;
    @Resource
    private PaasMenuModel paasMenuModel;
    @Resource
    private FormDataGetAnalysisDataHelp formDataGetAnalysisDataHelp;
    @Resource
    private CallCenterService callCenterService;
    @Resource
    private PaasAppModel paasAppModel;
    @Resource
    private CommonHelp commonHelp;
    @Resource
    private FormDataFormExplainHelper formDataFormExplainHelper;
    @Resource
    private LinkListService linkListService;
    @Resource
    private DetailTabConfigService detailTabConfigService;
    @Resource
    private UserTeamHelp userTeamHelp;
    @Resource
    private BusinessButtonService businessButtonService;
    @Resource
    private ContactPermissionServiceImpl contactPermissionService;
    @Resource
    private ContactUserModel contactUserModel;

    @Override
    public List<Integer> businessType() {
        return Collections.singletonList(XbbRefTypeEnum.CONTACT.getCode());
    }

    @Override
    public List<SummaryDataPoJo> getSummaryList(FormDataDetailDTO formDataDetailDTO, PaasFormDataEntityExt formData, PaasFormEntityExt formEntity, List<FieldAttrEntity> list, Map<String, FieldAttrEntity> explainMap, JSONObject data) throws XbbException {

        return ExplainUtil.getSpecialSummaryList(formEntity.getSummaryList(), data, explainMap, formData);
    }

    @Override
    public List<SummaryDataPoJo> getLabelList(FormDataDetailDTO formDataDetailDTO, PaasFormDataEntityExt formData, PaasFormEntityExt formEntity, List<FieldAttrEntity> list, Map<String, FieldAttrEntity> explainMap, JSONObject data) throws XbbException {
        // 解析标签
        return ExplainUtil.getSpecialSummaryList(formEntity.getLabelsList(), data, explainMap, formData);
    }


    @Override
    public List<FormTitlePoJo> getTitleList(FormDataDetailDTO formDataDetailDTO, PaasFormDataEntityExt formData, PaasFormEntityExt formEntity, List<FieldAttrEntity> list, Map<String, FieldAttrEntity> explainMap, JSONObject data) throws XbbException {
        return ExplainUtil.getSpecailFormTitle(JSONArray.parseArray(formEntity.getCustomTitle()), explainMap, data, list, formData);
    }

    @Override
    public List<MobileDetailMoneyItemPojo> getMobileDetailMoneyInfo(Integer distributorMark, String corpid, String userId, Integer businessType, Integer subBusinessType, Long dataId, JSONObject data, Map<String, FieldAttrEntity> explainMap, UserVO loginUser, PaasFormDataEntityExt paasFormDataEntityExt) throws XbbException {
        return new ArrayList<>();
    }

    @Override
    public JSONArray getBottomBlockInfo(String corpid, String userId, Integer businessType, PaasFormEntityExt formEntity, Long dataId, JSONObject data, Map<String, FieldAttrEntity> explainMap, PaasFormDataEntityExt entityExt, HandlerExplainDTO handlerExplainDTO) throws XbbException {
        JSONArray bottomBlockInfo = new JSONArray();
        Map<String, Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        Map<String, UserEntity> userMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        List<UserEntity> userEntityList;
        List<CustomerUserPojo> userPojoList = new ArrayList<>();
        List<String> userIdIn = new ArrayList<>();
        userIdIn.add("-1");
        param.put(StringConstant.CORPID, corpid);
        param.put(StringConstant.DEL, DelEnum.NORMAL);
        param.put(StringConstant.DATA_ID, dataId);
        List<ContactUserEntity> contactUserEntityList = contactUserModel.findEntitys(param);
        contactUserEntityList.forEach(item -> userIdIn.add(item.getUserId()));
        userEntityList = userModel.getByUserIdIn(corpid, userIdIn, true);
        userEntityList.forEach(item -> userMap.put(item.getUserId(), item));
        contactUserEntityList.forEach(item -> {
            UserEntity userEntity = userMap.get(item.getUserId());
            if (userEntity != null) {
                CustomerUserPojo customerUserPojo = new CustomerUserPojo();
                customerUserPojo.setUserId(userEntity.getUserId());
                customerUserPojo.setName(userEntity.getName());
                customerUserPojo.setAvatar(userEntity.getAvatar());
                customerUserPojo.setIsMain(item.getIsMain());
                userPojoList.add(customerUserPojo);
            }
        });
        bottomBlockInfo.add(new MobileDetailManagerBlockPojo(userPojoList));
        Long contactCustomerId = FastJsonHelper.getLongOrDefaultFromFormData(entityExt.getData(), ContactEnum.CUSTOMER_NAME.getAttr(), 0L);
        String contactCustomerName = FastJsonHelper.getStringOrDefaultFromFormData(entityExt.getData(), ContactEnum.CUSTOMER_NAME_LINK_TEXT.getAttr(), "");
        bottomBlockInfo.add(new MobileDetailDirectBlockPojo(contactCustomerId, XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), contactCustomerName));
        return bottomBlockInfo;
    }

    @Override
    public List<MobileDetailScriptPojo> getDetailShowScript(Integer businessType, UserVO loginUser, PaasFormDataEntityExt paasFormDataEntityExt, Map<String, FieldAttrEntity> explainMap) throws XbbException {
        return new ArrayList<>();
    }

    @Override
    public MobileDetailStatusPojo getDetailShowStatus(Integer businessType, JSONObject data) throws XbbException {
        return null;
    }

    @Override
    public Map<String, Object> getDetailShowOperation(String corpid, String userId, Integer businessType, Long dataId, JSONObject data) throws XbbException {
        return new HashMap<>(BasicConstant.DEFAULT_ACCURACY);
    }

    @Override
    public JSONObject returnSaasObject(String corpid, Integer businessType, UserVO userVO, PaasFormDataEntityExt paasFormDataEntityExt) {
        JSONObject saasReturnObj = new JSONObject();
        //快捷新建跟进记录tab栏显示与否
        saasReturnObj.put(StringConstant.QUICKFLLOWTAB, true);
        //动态显示与否
        saasReturnObj.put(StringConstant.DYNAMIC, true);
        //动态名称
        saasReturnObj.put(StringConstant.DYNAMICNAME, I18nMessageUtil.getMessage(I18nStringConstant.DYNAMIC));
        return saasReturnObj;
    }

    @Override
    public List<TopPermissionsPoJo> getMobileDetailBottomOperation(HandelDetailPojo handelDetailPojo, PaasFormEntityExt formEntity, PaasFormDataEntityExt formData, HandlerExplainDTO handlerExplainDTO, Map<String, FieldAttrEntity> explainMap) throws XbbException {
        Integer businessType = handelDetailPojo.getBusinessType();
        Integer businessType4Distributor = XbbRefTypeEnum.transferBusinessType4Distributor(businessType, handelDetailPojo.getDistributorMark());
        UserVO userVO = handelDetailPojo.getLoginUser();
        List<TopPermissionsPoJo> bottomOperationList = new ArrayList<>();
        List<MobileDetailBottomOperationEnum> bottomOperationEnumList = MobileDetailBottomOperationEnum.getByBusinessTypeAndPermission(businessType4Distributor, userVO.getPermSet());
        for (MobileDetailBottomOperationEnum anEnum : bottomOperationEnumList) {
            TopPermissionsPoJo topPermissionsPoJo = new TopPermissionsPoJo();
            BeanUtil.copyProperties(anEnum, topPermissionsPoJo);
            bottomOperationList.add(topPermissionsPoJo);
        }
        return bottomOperationList;
    }



    @Override
    public List<TopPermissionsPoJo> dingtalkHandleDetailWorkFlow(HandelDetailPojo handelDetailPojo, PaasFormEntityExt formEntity, PaasFormDataEntityExt formData, Map<String, FieldAttrEntity> explainMap) throws XbbException {
        String corpid = formEntity.getCorpid();
        UserVO userVO = handelDetailPojo.getLoginUser();
        Integer businessType = formEntity.getBusinessType();
        List<WorkFlowEnum> workFlowEnumList = WorkFlowEnum.getByBusinessTypeAndPermissionForDingtalk(businessType, userVO.getPermSet());
        List<String> aliasIn = new ArrayList<>();
        workFlowEnumList.forEach(item -> aliasIn.add(XbbRefTypeEnum.getByCode(item.getBusinessType()).getAlias()));
        Map<Integer, String> paasBusinessTypeToName = paasMenuModel.getMenuNameByAlias(aliasIn, corpid, businessType);

        List<TopPermissionsPoJo> topPermissions = businessButtonService.dingtalkDetailCommon(userVO, formEntity, explainMap, formData);
        List<LinkListPojo> linkList = formEntity.getLinkListList();
        topPermissions.addAll(linkListService.getDingtalkCommonButton(linkList, formData.getDel(), userVO, formData.getAppId(), formData.getFormId(), businessType, formEntity.getSaasMark(), corpid));

        for (WorkFlowEnum workFlowEnum : workFlowEnumList) {
            TopPermissionsPoJo topPermissionsPoJo = new TopPermissionsPoJo();
            BeanUtil.copyProperties(workFlowEnum, topPermissionsPoJo);
            if (Objects.equals(workFlowEnum.getFormRelation(), BasicConstant.ONE)) {
                NameUtil.changeValue(paasBusinessTypeToName, topPermissionsPoJo);
            }
            topPermissionsPoJo.setBusinessType(XbbRefTypeEnum.transferBusinessType2Index(workFlowEnum.getBusinessType()));
            topPermissionsPoJo.setDistributorMark(DistributorMarkEnum.OTHER.getCode());
            topPermissions.add(topPermissionsPoJo);
        }
        return topPermissions;
    }



    @Override
    public JSONArray getSecondTitleList(FormDataDetailDTO formDataDetailDTO, PaasFormDataEntityExt formData, PaasFormEntityExt formEntity, List<FieldAttrEntity> list, Map<String, FieldAttrEntity> explainMap, JSONObject data) throws XbbException {
        String corpid = formDataDetailDTO.getCorpid();
        Integer businessType = formDataDetailDTO.getBusinessType();
        Long formId = formData.getFormId();
        List<SummaryDataPoJo> summaryList = getSummaryList(formDataDetailDTO, formData, formEntity, list, explainMap, data);
        //todo 老哥客户详情那里没有调这个方法，需要和他确认一下
        handleSummarySpecialAttr(summaryList, data);
        specialTransferKeyToShowValue(corpid, summaryList, businessType,data, formId);
        return getSecondTitleList(summaryList, data, formDataDetailDTO.getCorpid(), formEntity.getId());
    }

    @Override
    public JSONArray getTagList(FormDataDetailDTO formDataDetailDTO, PaasFormDataEntityExt formData, PaasFormEntityExt formEntity, List<FieldAttrEntity> list, Map<String, FieldAttrEntity> explainMap, JSONObject data) throws XbbException {
        String corpid = formDataDetailDTO.getCorpid();
        Integer businessType = formEntity.getBusinessType();
        Long dataId = formData.getId();
        String userId = formDataDetailDTO.getUserId();
        Long formId = formData.getFormId();
        List<SummaryDataPoJo> labelsList = getLabelList(formDataDetailDTO, formData, formEntity, list, explainMap, data);
        handleSummarySpecialAttr(labelsList, data);
        return getTags(labelsList, corpid, businessType, dataId, userId);
    }

    @Override
    public String getTitle(FormDataDetailDTO formDataDetailDTO, PaasFormDataEntityExt formData, PaasFormEntityExt formEntity, List<FieldAttrEntity> list, Map<String, FieldAttrEntity> explainMap, JSONObject data) throws XbbException {
        List<FormTitlePoJo> formTitleList = getTitleList(formDataDetailDTO, formData, formEntity, list, explainMap, data);
        return TitleUtil.getWebTitle(formTitleList);
    }

    @Override
    public List<DetailTabPojo> handleDetailTab(HandelDetailPojo handelDetailPojo, PaasFormEntityExt formEntity, PaasFormDataEntityExt paasFormDataEntityExt, Map<String, FieldAttrEntity> explainMap, HandlerExplainVO handlerExplainVO, HandlerExplainDTO handlerExplainDTO) throws XbbException {
        Integer businessType = handelDetailPojo.getBusinessType();
        UserVO userVO = handelDetailPojo.getLoginUser();
        List<DetailTabPojo> tabPojoList = new ArrayList<>();
        String corpid = paasFormDataEntityExt.getCorpid();
        String userId = userVO.getUserId();
        List<BusinessDetailTabEnum> tabEnumList;
        String platFormEnum = handlerExplainDTO.getPlatform();
        // 判断当前公司有没有开启呼叫中心
        boolean isActiveCall = callCenterService.isOpenCallAndAgent(corpid, userId);
        boolean isActiveAliyunCall = callCenterService.isActiveAliyunCall(corpid, userId).IsActiveAliyunAndHasRole();
        if (Objects.equals(platFormEnum, PlatFormEnum.WEB.getValue())) {
            tabEnumList = BusinessDetailTabEnum.getByBusinessTypeAndPermission(businessType, userVO.getPermSet());
        } else {
            tabEnumList = BusinessDetailTabEnum.getByBusinessTypeAndPermissionForDingtalk(businessType, userVO.getPermSet());
        }
        // 兼容原呼叫中心  开通了其中一个就显示 通话记录tab
        isActiveCall = isActiveCall||isActiveAliyunCall;
        // 判断应用是否启用
        boolean isSmsUse = paasAppModel.validateAppEnable(null, XbbRefTypeEnum.GROUP_MESSAGE.getAlias(), 1, corpid);
        // 判断当前员工有没有短信权限
        boolean canSms = isSmsUse && userVO.getPermSet().contains(ProPermissionAliasEnum.SMS_VIEW.getAlias());

        // 获取对应businessType的alias
        List<String> aliasIn = BusinessDetailTabEnum.getAliasIn(tabEnumList);

        // 记录businessType与menuName的关系
        Map<Integer, String> paasBusinessTypeToName = paasMenuModel.getMenuNameByAlias(aliasIn, corpid, businessType);
        //协同团队
        Map<Long, List<String>> mainUserMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        Map<Long, List<String>> coUserMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        formDataFormExplainHelper.getUserIdMap(Collections.singletonList(paasFormDataEntityExt.getDataId()),corpid,businessType,false,mainUserMap,coUserMap);

        // 当前数据的创建人、负责人、协同人、当前操作人
        handlerExplainDTO.setLoginUser(userVO);
        handlerExplainDTO.setUserId(userId);
        handlerExplainDTO.setOwnerId(mainUserMap.get(paasFormDataEntityExt.getDataId()));
        handlerExplainDTO.setCoUserId(coUserMap.get(paasFormDataEntityExt.getDataId()));
        handlerExplainDTO.setCreatorId(paasFormDataEntityExt.getCreatorId());

        // 判断电话字段是否可见
        boolean contactMobile = commonHelp.attrCanSee(ContactEnum.PHONE.getAttr(), explainMap, handlerExplainDTO);
        if(contactMobile){
            List<? extends FieldAttrEntity> explainSubFormList = explainMap.get(ContactEnum.PHONE.getAttr()).getSubForm().getItems();
            Map<String, FieldAttrEntity> explainSubFormMap = new HashMap<>(explainSubFormList.size());
            explainSubFormList.forEach((item) -> explainSubFormMap.put(item.getAttr(), item));
            boolean text2CanSee = commonHelp.attrCanSee(StringConstant.PHONE_TEL_ATTR, explainSubFormMap, handlerExplainDTO);
            if(!text2CanSee){
                contactMobile = false;
            }
        }
        for (BusinessDetailTabEnum tabEnum : tabEnumList) {
            if (!isActiveCall && Objects.equals(tabEnum, BusinessDetailTabEnum.CONTACT_CALL_LOG)) {
                continue;
            }
            if (!canSms && Objects.equals(tabEnum, BusinessDetailTabEnum.CONTACT_SMS_SEND_AND_REPLY)) {
                continue;
            }
            // 短信往来tab
            if (!contactMobile && Objects.equals(tabEnum, BusinessDetailTabEnum.CONTACT_SMS_SEND_AND_REPLY)) {
                continue;
            }
            DetailTabPojo detailTabPojo = new DetailTabPojo();
            BeanUtil.copyProperties(tabEnum.getAnEnum(), detailTabPojo);
            changeTabEnumName(paasBusinessTypeToName, tabEnum, detailTabPojo);
            detailTabPojo.setAttr(detailTabPojo.getKey());
            tabPojoList.add(detailTabPojo);
        }
        handleTeamTab(tabPojoList, explainMap);
        List<LinkListPojo> linkList = JSONArray.parseArray(formEntity.getAssociationList(), LinkListPojo.class);
        handlerExplainVO.setAppId(formEntity.getAppId());
        handlerExplainVO.setFormId(formEntity.getId());
        // 公共tab
        tabPojoList.addAll(linkListService.commonTab(corpid, userVO, handlerExplainVO, handlerExplainDTO, businessType, paasFormDataEntityExt.getDel(), linkList));
        // tab排序
        tabPojoList = detailTabConfigService.handleDetailTabSort(userVO.getUserId(), corpid, handlerExplainVO.getFormId(), businessType, tabPojoList);
        return tabPojoList;
    }

    @Override
    public void checkPermission(PaasFormEntityExt formEntity, PaasFormDataEntityExt paasFormDataEntityExt, UserVO loginUser, Integer subBusinessType) throws XbbException {
        if (loginUser.isMaxDataPermission()){
            return ;
        }
        Integer flowStatus = paasFormDataEntityExt.getFlowStatus();
        Long menuId = formEntity.getMenuId();
        Integer saasMark = formEntity.getSaasMark();
        Integer businessType = formEntity.getBusinessType();

        // 查看权限校验
        verifyQueryPermission(businessType, loginUser,saasMark ,menuId ,flowStatus);
        //团队权限&共享权限校验
        contactPermissionService.checkPermission(formEntity, paasFormDataEntityExt, loginUser, subBusinessType);
    }


    @Override
    public JSONObject analysisData(PaasFormDataEntityExt paasFormDataEntityExt, HandlerExplainDTO handlerExplainDTO, HandlerExplainVO handlerExplainVO) throws XbbException {
        List<FieldAttrEntity> list = handlerExplainVO.getHeadList();
        Map<String, FieldAttrEntity> explainMap = new HashMap<>(list.size());
        list.forEach(item->explainMap.put(item.getAttr(), item));

        ParseSingleRowDataVO parseSingleRowDataVO = commonAnalysisData(paasFormDataEntityExt, handlerExplainDTO, handlerExplainVO, list, explainMap);
        JSONObject data = parseSingleRowDataVO.getResult();
        //处理千分位
        FormDataGetVO formDataGetVO = new FormDataGetVO();
        formDataGetVO.setData(data);
        formDataGetAnalysisDataHelp.analysisGetOfThousandBits(formDataGetVO, list, false);
        return data;
    }

    /**
     * 处理联系人summaryList中需要特殊处理的字段：联系人电话
     */
    private void handleSummarySpecialAttr(List<SummaryDataPoJo> summaryList, JSONObject data) throws XbbException {
        SummaryDataPoJo contactSummary = null;
        for (SummaryDataPoJo summaryItem : summaryList) {
            if (Objects.equals(summaryItem.getAttr(), ContactEnum.PHONE.getAttr())) {
                contactSummary  = summaryItem;
            }
        }
        if (Objects.nonNull(contactSummary)) {
            JSONArray phoneArray = FastJsonHelper.getJsonArrOrDefaultFromFormData(data, ContactEnum.PHONE.getAttr(), new JSONArray());
            List<Object> phoneList = new ArrayList<>();
            phoneArray.forEach(phoneItem -> {
                Object phoneNum = ((JSONObject) phoneItem).get("text_2");
                if (Objects.nonNull(phoneNum)) {
                    phoneList.add(phoneNum);
                }
            });
            contactSummary.setValue(phoneList);
            contactSummary.setPhoneExtra();
        }
    }
}
